<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script language="jscript">
        function convertCurrency(currencyDigits) {
// Constants:
            var MAXIMUM_NUMBER = 99999999999.99;
            // Predefine the radix characters and currency symbols for output:
            var CN_ZERO = "零";
            var CN_ONE = "壹";
            var CN_TWO = "贰";
            var CN_THREE = "叁";
            var CN_FOUR = "肆";
            var CN_FIVE = "伍";
            var CN_SIX = "陆";
            var CN_SEVEN = "柒";
            var CN_EIGHT = "捌";
            var CN_NINE = "玖";
            var CN_TEN = "拾";
            var CN_HUNDRED = "佰";
            var CN_THOUSAND = "仟";
            var CN_TEN_THOUSAND = "万";
            var CN_HUNDRED_MILLION = "亿";
            var CN_SYMBOL = "";
            var CN_DOLLAR = "元";
            var CN_TEN_CENT = "角";
            var CN_CENT = "分";
            var CN_INTEGER = "整";

// Variables:
            var integral;    // Represent integral part of digit number.
            var decimal;    // Represent decimal part of digit number.
            var outputCharacters;    // The output result.
            var parts;
            var digits, radices, bigRadices, decimals;
            var zeroCount;
            var i, p, d, ds;
            var quotient, modulus;

// Validate input string:
            currencyDigits = currencyDigits.toString();
            if (currencyDigits == "") {
                // alert("不能为空 请输入数字金额!如：123.23");
                return "";
            }
            if (currencyDigits.match(/[^,.\d]/) != null) {
                // alert("输入字符串中的字符无效!");
                return "";
            }
            if ((currencyDigits).match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
                // alert("请输入正确的数字金额!");
                return "";
            }

// Normalize the format of input digits:
            currencyDigits = currencyDigits.replace(/,/g, "");    // Remove comma delimiters.
            currencyDigits = currencyDigits.replace(/^0+/, "");    // Trim zeros at the beginning.
            // Assert the number is not greater than the maximum number.
            if (Number(currencyDigits) > MAXIMUM_NUMBER) {
                // alert("Too large a number to convert!");
                return "";
            }

// Process the coversion from currency digits to characters:
            // Separate integral and decimal parts before processing coversion:
            parts = currencyDigits.split(".");
            if (parts.length > 1) {
                integral = parts[0];
                decimal = parts[1];
                // Cut down redundant decimal digits that are after the second.
                decimal = decimal.substr(0, 2);
            } else {
                integral = parts[0];
                decimal = "";
            }
            // Prepare the characters corresponding to the digits:
            digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE);
            radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND);
            bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION);
            decimals = new Array(CN_TEN_CENT, CN_CENT);
            // Start processing:
            outputCharacters = "";
            // Process integral part if it is larger than 0:
            if (Number(integral) > 0) {
                zeroCount = 0;
                for (i = 0; i < integral.length; i++) {
                    p = integral.length - i - 1;
                    d = integral.substr(i, 1);
                    quotient = p / 4;
                    modulus = p % 4;
                    if (d == "0") {
                        zeroCount++;
                    } else {
                        if (zeroCount > 0) {
                            outputCharacters += digits[0];
                        }
                        zeroCount = 0;
                        outputCharacters += digits[Number(d)] + radices[modulus];
                    }
                    if (modulus == 0 && zeroCount < 4) {
                        outputCharacters += bigRadices[quotient];
                    }
                }
                outputCharacters += CN_DOLLAR;
            }
            // Process decimal part if there is:
            if (decimal != "") {
                for (i = 0; i < decimal.length; i++) {
                    d = decimal.substr(i, 1);
                    ds = decimal.substr(-1, 1);
                    if (d == 0) {
                        if (ds == 0) {
                            outputCharacters += "";
                        } else {
                            outputCharacters += digits[Number(d)];
                        }
                    } else {

                        outputCharacters += digits[Number(d)] + decimals[i];

                    }
                }
            }
            // Confirm and return the final output string:
            if (outputCharacters == "") {
                outputCharacters = CN_ZERO + CN_DOLLAR;
            }
            if (decimal == "") {
                outputCharacters += CN_INTEGER;
            }
            outputCharacters = CN_SYMBOL + outputCharacters;
            return outputCharacters;
        }
    </script>
</head>
<body style="padding: 0; margin: 0;font-family: '宋体';font-size: 12px;padding-left: 2rem;">
<div class="content">

    <div class="logo">
        <img style="width: 157px;height: 39px;" src=""
             alt="">
    </div>
    <div class="title" style="font-size: 26px; text-align: center;  margin-top: 0.5em;">购销合同</div>
    <div class="row header" style="margin: 0.5em 0; height: 2.5em;">
        <div class="col-6" style="float: left;">
            <div class="el">
                <div class="name" style="display: inline-block;">采购方（甲方）：</div>
                <div class="text" style="display: inline-block;" th:text="${company}"></div>
            </div>
            <div class="el" style="margin-top: 10px;">
                <div class="name" style="display: inline-block;">供货方（乙方）：</div>
                <div class="text" style="display: inline-block;">上海浦壹电子科技有限公司</div>
            </div>
        </div>
        <div class="col-4" style="float: right;padding-right: 22px;">
            <div class="el">
                <div class="name" style="display: inline-block;">订单编号：</div>
                <div class="text" style="display: inline-block;text-decoration: underline;" th:text="${orderNo}"></div>
            </div>
            <div class="el" style="margin-top: 10px;">
                <div class="name" style="display: inline-block;">签订日期：</div>
                <div class="text" style="display: inline-block;text-decoration: underline;" th:text="${signedTime}"></div>
            </div>
        </div>
    </div>
    <div class="list" style="margin-top: 20px;">
        <table style="border-collapse: collapse; border-spacing: 0; background-color: transparent; width: 98%;">
            <thead>
            <tr>
                <th class="t1" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">序号</th>
                <th class="t2" style="border: 1px solid #000; width: 10%;line-height: 30px;font-weight: normal;">型号</th>
                <th class="t3" style="border: 1px solid #000; width: 10%;line-height: 30px;font-weight: normal;">品牌</th>
                <th class="t4" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">年份</th>
                <th class="t5" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">数量</th>
                <th class="t6" style="border: 1px solid #000; width: 10%;line-height: 30px;font-weight: normal;">单位</th>
                <th class="t7" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">交期</th>
                <th class="t8" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">含税单价
                </th>
                <th class="t9" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">小计金额
                </th>
                <th class="t10" style="border: 1px solid #000; width: 5%;line-height: 30px;font-weight: normal;">备注</th>
            </tr>
            </thead>
            <tbody style="text-align: center;">

            <tr th:each="item,itemStat : ${list}">
                <td style="border: 1px solid #000; width: 5%;line-height: 30px;" class="t1" th:text="${itemStat.index + 1 }"></td>
                <td style="border: 1px solid #000; width: 10%;line-height: 30px;" class="t2" th:text="${item.partNo}">
                </td>
                <td style="border: 1px solid #000; width: 10%;line-height: 30px;" class="t3" th:text="${item.brandName}"></td>
                <td style="border: 1px solid #000; width: 15%;line-height: 30px;" class="t4" th:text="${item.dateCode}"></td>

                <td style="border: 1px solid #000; width: 10%;" class="t5" th:text="${item.amount}"></td>
                <td style="border: 1px solid #000; width: 5%;" class="t6">pcs</td>
                <td style="border: 1px solid #000; width: 10%;text-align: center;" class="t7"
                    th:text="${item.deliveryTerm}"></td>
                <td style="border: 1px solid #000; width: 10%;" class="t8"
                    th:text="${item.price}"></td>
                <td style="border: 1px solid #000; width: 10%;" class="t9"
                    th:text="${item.subtotal}"></td>
                <td style="border: 1px solid #000; width: 10%;" class="t10" th:text="${item.remark}">
                </td>
            </tr>
            <tr>
                <td style="border: 1px solid #000;height: 30px;" colspan="5">
                    <div class="box" style="position: relative;">
                        <div class="fl" style="position: absolute; left:0;top:-9px;padding-left: 5px;"
                             >方式交易：<span style="text-decoration: underline;">人民币交易</span></div>
                    </div>
                </td>
                <td style="border: 1px solid #000;height: 30px;" colspan="5">
                    <div class="box" style="position: relative;">
                        <div class="fr" style="position: absolute; left:0; top:-9px;text-align: left;padding-left: 5px;"
                             >商品总额：<span th:text="${totalPrice+' RMB'}" style="margin-left: 2rem;"></span></div>
                    </div>
                </td>
            </tr>
            <tr>
                <td id="combined" style="padding-left: 5px; border: 1px solid #000;height: 30px;text-align: left;" colspan="10">
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <div style="margin-top: 2em; font-weight: bold;">合同条款：</div>
    <div class="clause" style="line-height: 2;">
        <div>一、收货人：<span th:text="${userName}" style="text-decoration: underline;"></span>。</div>
        <div>二、联系方式：<span th:text="${userPhone}" style="text-decoration: underline;"></span>。</div>
        <div>三、收件地址：<span th:text="${userAddress}" style="text-decoration: underline;"></span>。</div>
        <div>四、货款结算方式：<span th:text="${settlementModes}" style="text-decoration: underline;"></span>。</div>
        <div>五、运输方式及费用承担：双方协定。</div>
        <div>六、质量验收标准：该器件为原厂，管脚无氧化。否则甲方有权利随时退货。</div>
        <div>七、质量异议时间期限：自签收日起<span style="text-decoration: underline;margin: 0 5px;">7</span>日内可提出异议。</div>
        <div>八、无需质检的电子元器件，一旦出现任何问题，乙方概不负责。</div>
        <div>九、本合同经双方单位盖章及负责人签字后生效。</div>
        <div>十、其它附加协议如下：</br>
            <div style="height: 60px;position: relative;line-height: 30px;margin: 12px 0 8px 0;padding: 0 3rem 0 0.4rem;" >
                <span th:text="${content}"></span>
                <div style="width: 95%;height: 0;border-bottom: 1px dashed black;position: absolute;top: 26px;left: 0.4rem;"></div>
                <div style="width: 95%;height: 0;border-bottom: 1px dashed black;position: absolute;bottom: 4px;left: 0.4rem;"></div>
            </div>
        </div>
    </div>
    <div class="line"
         style="width: 100%; height: 0.5px; background: #000; margin-top: 24px; margin-bottom: 24px;"></div>
    <div class="row footer" style="line-height: 1.5;  position: relative; min-height: 100px;">
        <div class="img"
             style="width: 190px; height: 190px; position: absolute; bottom: 20px; left: 65%; top: -8px;  z-index: 10; margin-bottom: 5em;">
            <img style="width:80%;height:80%;" src="
" alt="">
        </div>
        <div class="col-6" style="float: left; width: 54%;">
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">采购方：</div>
                <div class="text" style="float: left;text-decoration: underline;" th:text="${company}"></div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">采购方代表：</div>
                <div class="text" style="float: left;text-decoration: underline;" th:text="${contact}"></div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left;float: left;white-space: nowrap;">地址：</div>
                <div class="text" style="text-decoration: underline;"
                     th:text="${address}">
                </div>
            </div>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">电话：</div>
                <div class="text" style="float: left;text-decoration: underline; " th:text="${phone}"></div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">邮箱：</div>
                <div class="text" style="float: left;text-decoration: underline; " th:text="${email}">
                    </div>
            </div>

        </div>
        <div style="width: 3%;height: 3px;float: left;"></div>
        <div class="col-4" style="float: left; width: 43%;">
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">供货方：</div>
                <div class="text" style="float: left;">上海浦壹电子科技有限公(盖章)</div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">供货方代表：</div>
                <div class="text" style="float: left;">刘俊南</div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left;float: left;white-space: nowrap;">地址：</div>
                <div class="text" style="float: left;">上海市徐汇区虹漕路88号越虹广场A座15楼</div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">电话：</div>
                <div class="text" style="float: left;">021-60317249</div>
            </div>
            <br>
            <div class="row" style="width: 100%;">
                <div class="name" style="text-align: left; float: left;">邮箱：</div>
                <div class="text" style="float: left;">Vic_Liu@vadas-ic.com</div>
            </div>
        </div>
    </div>
</div>
<script th:inline="javascript">
    window.onload = function () {
        var innerText = [[${payfor}]];
        var numberText = convertCurrency(innerText);
        document.getElementById("combined").innerHTML = "合计人民币（大写）：" + numberText;
    }
</script>
</body>
</html>
